package hn.cch.http.server;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.stream.ChunkedWriteHandler;

/**
 * HTTP事件通道
 */
public class SimpleHttpChannel extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {


        ch.pipeline().addLast(new HttpServerCodec());//HTTP协议编码解码
        ch.pipeline().addLast(new ChunkedWriteHandler());//HTTP协议分块传输
        ch.pipeline().addLast(new HttpObjectAggregator(65536));//HTTP协议对象聚合
        ch.pipeline().addLast(new SimpleHttpHandler());// HTTP协议事件处理


    }
}
